#include <vector>
using std::vector;
class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        vector<int> res;
        unordered_set<int> hash1, hash2;
        for (int i = 0, j = 0;i < nums1.size() || j < nums2.size();++i, ++j)
        {
            if (i < nums1.size())
                hash1.insert(nums1[i]);
            if (j < nums2.size())
                hash2.insert(nums2[j]);
        }
        // if(hash1.size() > hash1.size())
        // std::swap(hash1,hash2);
        for (const auto& num : hash1)
        {
            if (hash2.count(num))
                res.emplace_back(num);
        }
        return res;
    }
};